import { Button } from 'antd'
import { useState } from 'react'
import { useMount } from 'ahooks'
import { WijmoBase } from '../../Router/Wijmo'


import { RedoOutlined, SearchOutlined, ExportOutlined, SortAscendingOutlined, PropertySafetyOutlined, FormOutlined } from '@ant-design/icons';

const wijmoConfig = async () => {

    return ({
        get: 'getBuyReturnInfo',
        params: {
            pageIndex: 1,
            pageSize: 10,
        },
        initParameter: {
            group: [],
            sort: [],
            groupPanel: true,
            filter: true,
            addSum: true,
            addIndex: true,
            topText: 'Ω',
            btmText: 'Ψ',
        },
        configuration: {
            allowSorting: 'MultiColumn',
            isReadOnly: true,
            selectionMode: 5,
            allowMerging: "Cells"
        },
        optionsBtn: click => ([
            {
                key: '0',
                type: 'group',
                label: '数据操作',
                children: [
                    {
                        key: 'modify',
                        label: (
                            <Button type='link' onClick={() =>
                                click('onModelBox', { title: '确认收货', type: 'WijmoComGoods', data: {}, width: 600 })
                            }>
                                <PropertySafetyOutlined style={{ color: '#13c2c2' }} />
                                确认收货
                            </Button>
                        )
                    },
                    {
                        key: 'A01',
                        label: (
                            <Button
                                type='link'
                                onClick={() => click('onModelBox', { title: '修改订单状态', type: 'WijmoComModifyStatus', data: {}, width: 800, classData: 2 })}
                            >
                                <FormOutlined style={{ color: '#13c2c2' }} />
                                修改状态
                            </Button>
                        )
                    },
                    { key: 'refresh', label: <Button type='link' onClick={() => click('onRefresh')} ><RedoOutlined style={{ color: '#13c2c2' }} />刷新数据</Button> },
                    { key: 'search', label: <Button type='link' onClick={() => click('onSearch')} ><SearchOutlined style={{ color: '#13c2c2' }} />条件搜索</Button> },
                    { key: 'sort', label: <Button type='link' onClick={() => click('onSort')} ><SortAscendingOutlined style={{ color: '#13c2c2' }} />排序方式</Button> },
                ],
            },
            {
                key: '2',
                type: 'group',
                label: '导出数据',
                children: [
                    { key: '2-1', label: <Button type='link' onClick={() => click('onSaveAct')}><ExportOutlined style={{ color: '#13c2c2' }} />导出选中数据</Button> },
                    { key: '2-2', label: <Button type='link' onClick={() => click('onSaveAll')}><ExportOutlined style={{ color: '#13c2c2' }} />导出全部数据</Button> },
                ],
            },
        ]),

        sortCriteria: [
            { id: 1, label: '商品名称', value: 'OProductName' },
            { id: 2, label: '退单日期', value: 'OCreateTime', default: 'desc@1' },
        ],
        columns: [
            {
                dataIndex: 'uuid',
                valueType: 'Hidden',
                hideInSearch: true
            },
            {
                title: '订单编号',
                dataIndex: 'orderNumber',
                valueType: 'Input',
                width: 180,
                align: 'center',
                hideInModify: true,
            },
            {
                title: '客户姓名',
                dataIndex: 'ulName',
                valueType: 'Input',
                width: 160,
                align: 'center',
                hideInModify: true,
            },
            {
                title: '联系方式',
                dataIndex: 'contactInfo',
                valueType: 'Input',
                width: 160,
                align: 'center',
                hideInModify: true,
            },
            {
                title: '产品名称',
                dataIndex: 'productName',
                valueType: 'Input',
                width: 240,
                align: 'center',
            },
            {
                title: '价格',
                dataIndex: 'price',
                valueType: 'Input',
                width: 80,
                align: 'center',
                hideInModify: true,
                hideInSearch: true,
            },
            {
                title: '数量',
                dataIndex: 'quantity',
                valueType: 'Input',
                width: 80,
                align: 'center',
                hideInModify: true,
                hideInSearch: true,
                aggregate: 1,
                format: 'n0',
                aggTitle: '总计',
                smlTitle: '小计',
            },
            {
                title: '单位',
                dataIndex: 'unit',
                valueType: 'Input',
                width: 80,
                align: 'center',
                hideInModify: true,
                hideInSearch: true,
            },
            {
                title: '金额',
                dataIndex: 'amount',
                valueType: 'Input',
                width: 120,
                align: 'center',
                hideInModify: true,
                hideInSearch: true,
                aggregate: 1,
                format: 'n2',
                aggTitle: '总计',
                smlTitle: '小计',
            },

            {
                title: '退款原因',
                dataIndex: 'refundReason',
                valueType: 'Input',
                width: 240,
                align: 'center',
                hideInModify: true,
                hideInSearch: true,
            },
            {
                title: '退款描述',
                dataIndex: 'refundDescription',
                valueType: 'Input',
                width: 240,
                align: 'center',
                hideInModify: true,
                hideInSearch: true,
            },
            {
                title: '退货状态',
                dataIndex: 'status',
                valueType: 'Input',
                width: 120,
                align: 'center',
                hideInModify: true,
                hideInSearch: true,
            },
            {
                title: '收货日期',
                dataIndex: 'receiptDate',
                valueType: 'Input',
                width: 200,
                align: 'center',
                hideInModify: true,
                hideInSearch: true,
            },
            {
                title: '供应商',
                dataIndex: 'supplierName',
                valueType: 'Input',
                width: 240,
                align: 'center',
            },

            {
                title: '创建日期',
                dataIndex: 'createTime',
                valueType: 'Input',
                width: 200,
                align: 'center',
                hideInAdded: true,
                hideInModify: true,
                hideInSearch: true
            },

            {
                title: '开始日期',
                dataIndex: 'begindate',
                valueType: 'DatePicker',
                picker: 'date',
                hideInTable: true,
            },
            {
                title: '结束日期',
                dataIndex: 'enddate',
                valueType: 'DatePicker',
                picker: 'date',
                hideInTable: true,
            },
        ],
    })
}

const TuiHuoInfo = () => {
    const [WijmoConfig, setWijmoConfig] = useState()
    useMount(async () => {
        setWijmoConfig(await wijmoConfig())
    })

    return (
        <div>
            {WijmoConfig && <WijmoBase Config={WijmoConfig} />}
        </div>
    )
}

export default TuiHuoInfo